﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using HWR_Ants.Classes;

namespace HWR_Ants.Forms
{
    public partial class fHWR_Ants : Form
    {
        private TSP_File tspFile;

        public fHWR_Ants()
        {
            InitializeComponent();
            openFileDialog1.InitialDirectory = Application.StartupPath;
            openFileDialog1.RestoreDirectory = true;
        }

        private void öffnenToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog1.FileName.Contains("\\"))
                    openFileDialog1.InitialDirectory = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.LastIndexOf("\\"));
                
                if (File.Exists(openFileDialog1.FileName))
                {
                    try
                    {
                        tspFile = new TSP_File(openFileDialog1.FileName);
                        fTSP_Painting tsp = new fTSP_Painting();
                        tsp.TspFileToPaint = tspFile;
                        tsp.Show();
                    }
                    catch (Exception ex)
                    {
                        tspFile = null;
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }

        private void einstellungenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fOptions fo = new fOptions();
            fo.Show();
        }

        private void ausgbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fAusgabe fa = new fAusgabe();
            fa.Show();
        }

        private void hilfeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fAbout fa = new fAbout();
            fa.Show();
        }

        private void bt_Start_Click(object sender, EventArgs e)
        {
            if (bt_Start.Text == "Start")
            {
                bt_Start.Text = "Stopp";
            }
            else
            {
                bt_Start.Text = "Start";
            }
        }
    }
}
